import {currentMenu} from '@/commonApi/menu'
import {menuToRoute} from '@/util/menuToRoute'
export default {
    state:{
        menus:null
    },
    mutations:{
        setMenu(state,val){
          state.menus = val
        }
    },
    actions:{
        getCurrentMenu({commit}){
            return new Promise((resolve,reject)=>{
                currentMenu().then(v=>{
                    if(v.ok){
                        const route = menuToRoute(v.data)
                        commit('setMenu',route);
                        resolve(route)
                    }else{
                        reject(false)
                    }
                })
            })
        }
    },
    getters:{

    }
}